<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"  
                xmlns:h="http://java.sun.com/jsf/html"  
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../templates/FoodSageTemplate.xhtml">

    <ui:define name="logout">
        <p:commandLink id="logoutLink" actionListener="#{touristLogoutManagedBean.doLogout}" value="#{bundle['login.logout.label']}" ajax="false" immediate="true" />
    </ui:define>

    <ui:define name="main_menu">
        <f:view beforePhase="#{itineraryChooseItineraryTypeManagedBean.initView}"/>
        <p:menubar model="#{itineraryChooseItineraryTypeManagedBean.touristMainMenuModel}"/>
    </ui:define>

    <ui:define name="nav_menu">
        <p:menu model="#{itineraryChooseItineraryTypeManagedBean.touristNavMenuModel}"/>
    </ui:define>

    <ui:define name="content">
        <f:view beforePhase="#{customerULPManagerBean.initViewLoyaltyPointAccount}"></f:view>
        <h:form id="formMain">
            <h1>Loyalty Point Account</h1>         

            <p:panel header="View Loyalty Point Account">
                <p:fieldset>
                    <h:outputText value="UNIFIED LOYALTY PROGRAM ACCOUNT" style="font-weight:bold; text-align:center; font-size:14px" />
                    <br/>
                    <h:outputText value="CUSTOMER NAME #{customerULPManagerBean.customer.tourist.firstName} #{customerULPManagerBean.customer.tourist.lastName}"  style="font-weight:bold; text-align:center; font-size:14px"/>
                    <br/>
                    <h:outputText value="NUMBER OF POINTS: #{customerULPManagerBean.customer.point}" style="font-weight:bold; text-align:center; font-size:14px" />
                </p:fieldset>
                <br/>
                <p:accordionPanel autoHeight="false">
                    <p:tab title="Point Accumulations (Double click to select)">
                        <p:dataTable var="accumulation" value="#{customerULPManagerBean.accumulationList}" paginator="true" 
                                     rows="10" emptyMessage="No accumulation recorded" selection="#{customerULPManagerBean.selectedAccumulation}" 
                                     selectionMode="single" rowSelectListener="#{customerULPManagerBean.onRowSelectNavigateViewAccumulation}"
                                     dblClickSelect="true">
                            <p:column sortBy="#{accumulation.reservation.id}" filterBy="#{accumulation.reservation.id}">
                                <f:facet name="header">
                                    <h:outputText value="ID" />
                                </f:facet>
                                <h:outputText value="#{accumulation.reservation.id}" />
                            </p:column>

                            <p:column sortBy="#{accumulation.reservation.branch.stakeholder.corpName}" filterBy="#{accumulation.reservation.branch.stakeholder.corpName}">
                                <f:facet name="header">
                                    <h:outputText value="Reservation with" />
                                </f:facet>
                                <h:outputText value="#{accumulation.reservation.branch.stakeholder.corpName}" />
                            </p:column>

                            <p:column sortBy="#{accumulation.reservationDate}" filterBy="#{accumulation.reservationDate}">
                                <f:facet name="header">
                                    <h:outputText value="Reservation Date" />
                                </f:facet>
                                <h:outputText value="#{accumulation.reservationDate}">
                                    <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                                </h:outputText>
                            </p:column>



                            <p:column sortBy="#{accumulation.totalBill}" filterBy="#{accumulation.totalBill}">
                                <f:facet name="header">
                                    <h:outputText value="Total Bill Value" />
                                </f:facet>
                                <h:outputText value="#{accumulation.totalBill} SGD" />
                            </p:column>

                            <p:column sortBy="#{accumulation.totalPoint}" filterBy="#{accumulation.totalPoint}">
                                <f:facet name="header">
                                    <h:outputText value="Points Received" />
                                </f:facet>
                                <h:outputText value="#{accumulation.totalPoint} points" />
                            </p:column>                 

                        </p:dataTable>
                    </p:tab>

                    <p:tab title="Point Redemptions">
                        <p:dataTable var="redemption" value="#{customerULPManagerBean.redemptionList}" paginator="true" 
                                     rows="10" emptyMessage="No pending application" selection="#{customerULPManagerBean.selectedRedemption}" 
                                     selectionMode="single" rowSelectListener="#{customerULPManagerBean.onRowSelectNavigateViewRedemption}"
                                     dblClickSelect="true">

                            <p:column sortBy="#{redemption.id}" filterBy="#{redemption.id}">
                                <f:facet name="header">
                                    <h:outputText value="ID" />
                                </f:facet>
                                <h:outputText value="#{redemption.id}" />
                            </p:column>

                            <p:column sortBy="#{redemption.referenceNumber}" filterBy="#{redemption.referenceNumber}">
                                <f:facet name="header">
                                    <h:outputText value="Reference Number" />
                                </f:facet>
                                <h:outputText value="#{redemption.referenceNumber}" />
                            </p:column>

                            <p:column sortBy="#{redemption.dateCreated}" filterBy="#{redemption.dateCreated}">
                                <f:facet name="header">
                                    <h:outputText value="Redemption Date" />
                                </f:facet>
                                <h:outputText value="#{redemption.dateCreated}" >
                                    <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                                </h:outputText>
                            </p:column>

                            <p:column sortBy="#{redemption.dateExpired}" filterBy="#{redemption.dateExpired}">
                                <f:facet name="header">
                                    <h:outputText value="Expiry Date" />
                                </f:facet>
                                <h:outputText value="#{redemption.dateExpired}">
                                    <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                                </h:outputText>
                            </p:column>

                            <p:column sortBy="#{redemption.redemptionList.pointsToRedeem}" filterBy="#{redemption.redemptionList.pointsToRedeem}">
                                <f:facet name="header">
                                    <h:outputText value="Points Used" />
                                </f:facet>
                                <h:outputText value="#{redemption.redemptionList.pointsToRedeem} points" />
                            </p:column>

                            <p:column sortBy="#{customerULPManagerBean.returnRedemptionStatus(redemption.dateUsed==null)}" filterBy="#{customerULPManagerBean.returnRedemptionStatus(redemption.dateUsed==null)}">
                                <f:facet name="header">
                                    <h:outputText value="Status" />
                                </f:facet>
                                <h:outputText value="#{customerULPManagerBean.returnRedemptionStatus(redemption.dateUsed==null)}" />
                            </p:column>
                        </p:dataTable>
                    </p:tab> 
                </p:accordionPanel> 
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>